package com.mediocre.common.model;

import com.mediocre.common.enumeration.RespResult;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author 张伟
 * @desc
 * @date 2022/1/2 下午11:05
 * @modifier
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespBean<T> implements Serializable {

    private Integer status;
    private String msg;
    private T obj;

    public static RespBean ok(String msg, Object obj) {
        return new RespBean(RespResult.SUCCESS.getCode(), msg, obj);
    }

    public static RespBean error(Object obj) {
        return new RespBean(RespResult.FAILURE.getCode(), RespResult.FAILURE.getMsg(), obj);
    }
}
